package com.dabbo.starship.cell;
import java.rmi.RemoteException;

import com.dabbo.starship.interfaces.Block;
import com.dabbo.starship.interfaces.Cell;
import com.dabbo.starship.interfaces.CellLocationInterface;
import com.dabbo.starship.shared.CellLocation;

public class CellDoor extends CellDefault {
	
	private static final long serialVersionUID = 4211894259980475386L;

	protected Block 		linkedBlock		= null;
	protected CellLocation 	linkedCell		= null;

	public CellDoor(Block parent) throws RemoteException {
		super(parent);
		this.cellType = Cell.CELL_DOOR;
		this.cargoAllowed = false;
		this.passable = true;
		this.powerOutput = 0;
		this.doorSecure = false;
	}

	@Override
	public void setExit(Block parentBlock, CellLocationInterface parentCell, Block linkedBlock, CellLocationInterface linkedCell, boolean callBack) throws RemoteException {
		this.linkedBlock = linkedBlock;
		this.linkedCell = (CellLocation) linkedCell;
		if (callBack) {
			linkedBlock.setCell(new CellDoor(this.parentBlock), linkedCell);
			linkedBlock.getCell(linkedCell).setExit(linkedBlock, linkedCell, parentBlock, parentCell, false);
		}
	}

	public CellLocationInterface getExitCell() throws RemoteException {
		return this.linkedCell;
	}

	public Block getExitBlock() throws RemoteException {
		return this.linkedBlock;
	}

}
